ARM 编译 x86
这里主要通过 arch
命令来使用不同架构运行一个指令
# launch x86_64 shell
arch -x86_64 zsh
# install x86_64 variant of brew
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# install x86_64 variant of clang
arch -x86_64 /usr/local/bin/brew install llvm
此时我们安装了一个 x86
版本的 brew
, 和 arm64
版本会共存
# arm64 (default) location
/opt/homebrew/bin/brew
# x86_64 location
/usr/local/bin/brew
而 clang
会在电脑中存在三份
# Apple arm64 (default) location
/usr/bin/clang
# brew arm64 location
/opt/homebrew/opt/llvm/bin/clang
# brew x86_64 location
/usr/local/opt/llvm/bin/clang
此时,如果希望使用 cmake
编译 x86
版本的动态库,则可以按照下方来执行
arch -x86_64 /usr/local/opt/cmake/bin/cmake